
const app = getApp()
Page({
  data: {
    nbFrontColor: '#000000',
    nbBackgroundColor: '#ffffff',
    inputSel: '',
    classifyOnes: ["计算机与互联网", "经济", "文学", "小说", "情感", "社会科学", "大中专教材教辅", "管理", "健身与 保健", "文化", "中小学教辅", "医学", "理想", "科技", "童书", "绘画", "书法", "心理学", "历史", "传记", "工业技术", "法律", "温暖", "金融与投资", "婚恋与两性", "科普读物", "音乐", "家居", "艺术", "动漫", "建筑", "摄影", "外语学习", "考试", "电子与通信"],
    listName: '全部分类',
    booklist: [],
    pageSize: 10,
    isShow: false,
    active: 0,
    finddata:[],
    "bnrUrl": [{
      "url": "../../imgs/timg (1).jpg"
    }, {
      "url": "../../imgs/timg.jpg"
    }, {
      "url": "../../imgs/timg (2).jpg"
    }, ],
    hotArry: [{
        "url": "http://img3m1.ddimg.cn/31/4/20039611-1_l_9.jpg",
        "title": "小熊和最好的爸爸",
        "sub": "  亚历克斯·沃尔"
      },
      {
        "url": "http://img3m5.ddimg.cn/56/4/23761145-1_l_6.jpg",
        "title": "人间失格",
        "sub": "著杨伟"
      },
      {
        "url": "http://img3m1.ddimg.cn/80/1/23778791-1_l_10.jpg",
        "title": "少年读史记",
        "sub": "著史丹利"
      },
      {
        "url": "http://img3m6.ddimg.cn/34/34/25289386-1_l_1.jpg",
        "title": "小王子",
        "sub": "郑克鲁法语原文直译"
      },

    ],
    newArry: [{
        "url": "http://img3m9.ddimg.cn/83/1/28986689-1_l_3.jpg",
        "title": "把自己作为方进",
      },
      {
        "url": "http://img3m9.ddimg.cn/84/6/27914619-1_l_7.jpg",
        "title": "中国文化",
      },
      {
        "url": "http://img3m0.ddimg.cn/75/24/27875010-1_l_5.jpg",
        "title": "夜航船",
      }
    ]
  },
  onLoad() {
    this.setData({
      nbFrontColor: '#ffffff',
      nbBackgroundColor: '#000000',
    })
    var { pageSize } = this.data
    
  },
  onReachBottom() {
    var { pageSize } = this.data
    pageSize = pageSize + 10
    var that = this;
    
  },
  searchBook: function () {
    let {inputSel}=this.data;
    const db = wx.cloud.database();
    db.collection("data_book").where({
      title:db.RegExp({
        regexp:".*"+inputSel,
        option:"i"
      })
      }).get({
      success(data){
        this.finddata = data.data[0];
          wx.showModal({
            title: '此书存在，提示位置',
            content: this.finddata.position,
            showCancel: false,
            success(res) {
              
            } 
          })
    
        console.log(this.finddata)
        
      },
     
    })

  },
  viewAllList: function () {
    var isShow = this.data.isShow
    this.setData({
      isShow: isShow ? false : true
    })
  },
  bookDetail: function (e) {
    var bookMsg = e.currentTarget.dataset.msg
    var {
      isbncode
    } = bookMsg
    wx.navigateTo({
      url: '/pages/books-detail/books-detail?isbncode=' + isbncode
    })
  },
  booksListBtn: function (e) {

  },
  borrow: function () {
    wx.navigateTo({
      url: '/pages/borrow/borrow'
    })
  },
  return: function () {
    wx.navigateTo({
      url: '/pages/return/return'
    })
  },
  mime: function () {
    wx.navigateTo({
      url: '/pages/mine/mine'
    })
  },

  chooseClassify: function (e) {
    var index = e.target.offsetTop / 31
    this.setData({
      listName: this.data.classifyOnes[index],
      isShow: false
    })
  },
  turnOff: function () {
    this.setData({
      isShow: false
    })
  },

  onChange(event) {
   
    this.setData({
      active: event.detail
    });
  },
})